#include <iostream>
#include <string.h>
using namespace std;

char s1[1001];
char s2[1001];
int i, j, len1, len2;
int dp[1001][1001];


int main() 
{
	while ( cin >> s1 >> s2 ) {
		len1 = strlen(s1);
		len2 = strlen(s2);
		for ( i = 0; i < len1; ++ i)
			for ( j = 0; j < len2; ++ j) {
				dp[i][j] = (s1[i] == s2[j]);
				if ( (i-1) >= 0 && (j-1) >= 0 ) dp[i][j] += dp[i-1][j-1];
				if ( (i-1) >= 0 ) dp[i][j] = max(dp[i][j], dp[i-1][j]);					
				if ( (j-1) >= 0 ) dp[i][j] = max(dp[i][j], dp[i][j-1]);
			}
		cout << dp[len1-1][len2-1];
	}
	return 0;
}
